import 'package:flutter/material.dart';

class AlertDialogUtil {
  show(BuildContext context, String title, String content,
      {VoidCallback onPressed}) {
    if (onPressed != null) {
      showDialog(
          context: context,
          barrierDismissible: false,
          builder: (BuildContext context) {
            return AlertDialog(
              title: Text(title),
              content: Text(content),
              actions: <Widget>[
                FlatButton(child: Text("确定"), onPressed: onPressed)
              ],
            );
          });
    } else {
      showDialog(
          context: context,
          barrierDismissible: false,
          builder: (BuildContext context) {
            return AlertDialog(
              title: Text(title),
              content: Text(content),
              actions: <Widget>[
                FlatButton(
                    child: Text("确定"),
                    onPressed: Navigator.of(context).pop)
              ],
            );
          }
          );
    }
  }
}
